package com.sina.weibo;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.sina.weibo.models.MBlog;
import com.sina.weibo.models.User;
import com.sina.weibo.models.UserInfo;
import com.sina.weibo.view.MBlogListItemView;
import com.sina.weibo.view.MainListItemView;
import java.io.File;
import java.util.Iterator;
import java.util.List;

public class UserTopicAttentionList extends ListBaseActivity
  implements View.OnClickListener
{
  private static final int ACT_ADD = 0;
  private static final int ACT_REMOVE = 1;
  public static final int BACK2HOME = 1;
  private static final int ITEMMENU_BACK = 0;
  private static final int ITEMMENU_BOOKMARK = 3;
  private static final int ITEMMENU_COMMENT = 2;
  private static final int ITEMMENU_FORWARD = 1;
  public static final int LOAD_MORE = 0;
  public static final int MODE_SEARCH = 0;
  public static final int RELOAD = 1;
  public static final int SWITCHUSER;
  Button ivTopicAttent;
  Button ivTopicComment;
  Button ivTopicHome;
  Button ivTopicReload;
  private int loadMode = 1;
  LinearLayout lyTopicToolbar;
  WeiboTopicListAdapter mAdapter;
  private int mBeRelated = 0;
  private String mCacheDir;
  private String mCurNick = "";
  private String mCurUid = "";
  private String mFavId;
  private ListView mLvUser;
  private int mMode = 0;
  private String mNick;
  private String mOwner;
  private String mPassword;
  private boolean mPrefAutoloadMore;
  private int mPrefPictureSize;
  private boolean mPrefShowPicture;
  private ProgressBar mProgressBar;
  private String mQuery;
  private int mReadMode;
  private LinearLayout mReloadItem;
  private String mUid;
  private User mUser;
  private String mUsername;

  private void load_settings()
  {
    SharedPreferences localSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    boolean bool1 = MainTabActivity.mPrefShowPicture;
    this.mPrefShowPicture = bool1;
    int i = MainTabActivity.mPrefPictureSize;
    this.mPrefPictureSize = i;
    boolean bool2 = MainTabActivity.mPrefAutoloadMore;
    this.mPrefAutoloadMore = bool2;
    int j = getIntent().getExtras().getInt("mode");
    this.mMode = j;
  }

  protected void doItemMenu(String paramString)
  {
  }

  protected BaseAdapter getAdapter()
  {
    if (this.mAdapter == null)
    {
      WeiboTopicListAdapter localWeiboTopicListAdapter = new WeiboTopicListAdapter(this);
      this.mAdapter = localWeiboTopicListAdapter;
    }
    return this.mAdapter;
  }

  protected List<CharSequence> getMenuContent()
  {
    return null;
  }

  protected Object[] getMessages(int paramInt1, int paramInt2)
  {
    Object[] arrayOfObject1 = (Object[])0;
    try
    {
      if (this.mUser == null)
      {
        RPCHelper localRPCHelper1 = RPCHelper.getInstance(getApplication());
        String str1 = this.mUsername;
        String str2 = this.mPassword;
        User localUser1 = localRPCHelper1.login(str1, str2);
        this.mUser = localUser1;
      }
      if (this.mUser == null)
      {
        Object localObject = null;
        return localObject;
      }
      if (this.mUid == null)
      {
        RPCHelper localRPCHelper2 = RPCHelper.getInstance(getApplication());
        User localUser2 = this.mUser;
        String str3 = this.mNick;
        String str4 = localRPCHelper2.getUserInfo(localUser2, null, str3).uid;
        this.mUid = str4;
      }
      switch (this.mMode)
      {
      default:
        label136: int j = ((Integer)arrayOfObject1[2]).intValue();
        this.mBeRelated = j;
        if (arrayOfObject1 != null)
          break;
      case 0:
      }
      Object[] arrayOfObject3;
      for (int i = this.mTotals; ; arrayOfObject2 = arrayOfObject3)
      {
        this.mTotals = i;
        arrayOfObject2 = arrayOfObject1;
        break;
        RPCHelper localRPCHelper3 = RPCHelper.getInstance(getApplication());
        User localUser3 = this.mUser;
        String str5 = this.mQuery;
        int k = this.mPrefPictureSize;
        int m = paramInt1;
        int n = paramInt2;
        arrayOfObject1 = localRPCHelper3.searchMBlog(localUser3, str5, k, m, n);
        break label136;
        arrayOfObject3 = ((Integer)arrayOfObject1[0]).intValue();
      }
    }
    catch (RPCHelper.HttpException localHttpException)
    {
      while (true)
        Object[] arrayOfObject2 = null;
    }
  }

  protected void handleListItemClickEvent(int paramInt)
  {
    int i = this.mExpectItem - 1;
    switch (paramInt)
    {
    case 0:
    default:
    case 1:
    }
    while (true)
    {
      return;
      switch (this.mMode)
      {
      default:
        break;
      case 0:
        MBlog localMBlog = (MBlog)this.mList.get(i);
        Intent localIntent1 = new Intent();
        Context localContext = getApplicationContext();
        Intent localIntent2 = localIntent1.setClass(localContext, DetailWeiboActivity.class).putExtra("KEY_MBLOG", localMBlog);
        User localUser = StaticInfo.mUser;
        Intent localIntent3 = localIntent2.putExtra("KEY_MUSR", localUser);
        startActivity(localIntent3);
      }
    }
  }

  protected void handleTaskResult(List<?> paramList, String paramString)
  {
    if (this.mPgToast != null)
      this.mPgToast.cancel();
    if (paramList != null)
      if (this.mList == null)
      {
        this.mList = paramList;
        String str1 = this.mUid;
        this.mCurUid = str1;
        String str2 = this.mNick;
        this.mCurNick = str2;
        label52: if (this.mBeRelated != 1)
          break label251;
        this.ivTopicAttent.setText(2131427530);
        this.ivTopicAttent.setCompoundDrawablesWithIntrinsicBounds(0, 2130837595, 0, 0);
      }
    while (true)
    {
      this.lyTopicToolbar.setVisibility(0);
      return;
      if (paramList.size() > 0)
      {
        if (this.mMode != 0)
          break;
        Iterator localIterator1 = paramList.iterator();
        while (localIterator1.hasNext())
        {
          MBlog localMBlog = (MBlog)localIterator1.next();
          Iterator localIterator2 = this.mList.iterator();
          String str3;
          String str4;
          do
          {
            if (!localIterator2.hasNext())
            {
              boolean bool = this.mList.add(localMBlog);
              break;
            }
            Object localObject = localIterator2.next();
            str3 = localMBlog.mblogid;
            str4 = ((MBlog)localObject).mblogid;
          }
          while (!str3.equals(str4));
        }
        break;
      }
      int i = this.mPage - 1;
      this.mPage = i;
      break;
      String str5 = getString(2131427376);
      Toast.makeText(this, str5, 0).show();
      break label52;
      label251: this.ivTopicAttent.setCompoundDrawablesWithIntrinsicBounds(0, 2130837598, 0, 0);
      this.ivTopicAttent.setText(2131427430);
    }
  }

  protected void handleTitleBarEvent(int paramInt)
  {
    switch (paramInt)
    {
    default:
    case 0:
    case 1:
    }
    while (true)
    {
      return;
      if (!this.mTaskFree)
        continue;
      this.loadMode = 1;
      reloadList();
      continue;
      finish();
    }
  }

  protected void loadCache()
  {
  }

  protected void loadCache(int paramInt)
  {
  }

  protected void loadMore(int paramInt)
  {
    reloadBegine(0);
    this.mExpectItem = paramInt;
    ListBaseActivity.FetchDataTask localFetchDataTask1 = new ListBaseActivity.FetchDataTask(this);
    this.mTask = localFetchDataTask1;
    int i = this.mPage + 1;
    this.mPage = i;
    String str = String.valueOf(i);
    ListBaseActivity.FetchDataTask localFetchDataTask2 = this.mTask;
    String[] arrayOfString = new String[1];
    arrayOfString[0] = str;
    AsyncTask localAsyncTask = localFetchDataTask2.execute(arrayOfString);
  }

  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    super.onActivityResult(paramInt1, paramInt2, paramIntent);
    if (paramInt1 == 1)
    {
      setResult(-1, null);
      finish();
    }
  }

  public void onClick(View paramView)
  {
    try
    {
      Button localButton1 = this.ivTopicAttent;
      if (paramView == localButton1)
      {
        int i = this.mBeRelated;
        if (i != 1);
      }
    }
    catch (Exception localException1)
    {
      try
      {
        RPCHelper localRPCHelper1 = RPCHelper.getInstance(getApplication());
        User localUser1 = this.mUser;
        String str1 = this.mFavId;
        boolean bool1 = localRPCHelper1.attendTopic(localUser1, 1, str1);
        boolean bool2 = bool1;
        label57: int j = 1;
        if (j != 0)
        {
          this.ivTopicAttent.setText(2131427430);
          this.ivTopicAttent.setCompoundDrawablesWithIntrinsicBounds(0, 2130837598, 0, 0);
          String str2 = getString(2131427335);
          Toast.makeText(this, str2, 1).show();
        }
        if (j != 0)
        {
          int k = this.mBeRelated;
          int m = 1 - k;
          this.mBeRelated = m;
        }
        while (true)
        {
          return;
          RPCHelper localRPCHelper2 = RPCHelper.getInstance(getApplication());
          User localUser2 = this.mUser;
          String str3 = this.mQuery;
          boolean bool3 = localRPCHelper2.attendTopic(localUser2, 0, str3);
          if (!bool3)
            break;
          this.ivTopicAttent.setCompoundDrawablesWithIntrinsicBounds(0, 2130837595, 0, 0);
          this.ivTopicAttent.setText(2131427530);
          String str4 = getString(2131427333);
          Toast.makeText(this, str4, 1).show();
          break;
          localException1 = localException1;
          Toast.makeText(this, "Mutipulation failed", 1).show();
          continue;
          Button localButton2 = this.ivTopicComment;
          if (paramView == localButton2)
          {
            StringBuilder localStringBuilder = new StringBuilder("#");
            String str5 = this.mQuery;
            String str6 = str5 + "#" + " ";
            Intent localIntent1 = Utils.editTopicBlog(this, str6);
            startActivity(localIntent1);
            continue;
          }
          Button localButton3 = this.ivTopicHome;
          if (paramView == localButton3)
          {
            Intent localIntent2 = new Intent(this, MainTabActivity.class);
            startActivity(localIntent2);
            finish();
            continue;
          }
          Button localButton4 = this.ivTopicReload;
          if (paramView == localButton4)
          {
            if (!this.mTaskFree)
              continue;
            this.loadMode = 1;
            reloadList();
            continue;
          }
          super.onClick(paramView);
        }
      }
      catch (Exception localException2)
      {
        break label57;
      }
    }
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    String str1 = getString(2131427528);
    String str2 = getString(2131427456);
    String str3 = getString(2131427374);
    setTitleBar(1, str1, str2, str3);
    Button localButton1 = (Button)findViewById(2131624184);
    this.ivTopicAttent = localButton1;
    this.ivTopicAttent.setOnClickListener(this);
    Button localButton2 = (Button)findViewById(2131624185);
    this.ivTopicComment = localButton2;
    this.ivTopicComment.setOnClickListener(this);
    Button localButton3 = (Button)findViewById(2131624187);
    this.ivTopicHome = localButton3;
    this.ivTopicHome.setOnClickListener(this);
    Button localButton4 = (Button)findViewById(2131624186);
    this.ivTopicReload = localButton4;
    this.ivTopicReload.setOnClickListener(this);
    LinearLayout localLinearLayout = (LinearLayout)findViewById(2131624183);
    this.lyTopicToolbar = localLinearLayout;
    String str4 = getCacheDir().getPath();
    this.mCacheDir = str4;
    String str5 = StaticInfo.mUsername;
    this.mUsername = str5;
    String str6 = StaticInfo.mPassword;
    this.mPassword = str6;
    String str7 = getIntent().getStringExtra("query");
    this.mQuery = str7;
    String str8 = getIntent().getStringExtra("favid");
    this.mFavId = str8;
    ListView localListView = this.mlvBase;
    this.mLvUser = localListView;
    this.mLvUser.setVisibility(4);
    setResult(-1, null);
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    getMenuInflater().inflate(2131558403, paramMenu);
    if (this.mBeRelated == 1);
    for (MenuItem localMenuItem1 = paramMenu.findItem(2131624246); ; localMenuItem1 = paramMenu.findItem(2131624245))
    {
      MenuItem localMenuItem2 = localMenuItem1.setVisible(1);
      return true;
    }
  }

  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    try
    {
      switch (paramMenuItem.getItemId())
      {
      default:
      case 2131624249:
      case 2131624245:
      case 2131624246:
      case 2131624247:
        while (true)
        {
          int i = 0;
          while (true)
          {
            return i;
            Intent localIntent1 = new Intent(this, MainTabActivity.class);
            startActivity(localIntent1);
            finish();
            i = 1;
            continue;
            RPCHelper localRPCHelper1 = RPCHelper.getInstance(getApplication());
            User localUser1 = this.mUser;
            String str1 = this.mQuery;
            boolean bool1 = localRPCHelper1.attendTopic(localUser1, 0, str1);
            String str2 = getString(2131427333);
            Toast.makeText(this, str2, 1).show();
            this.mBeRelated = 1;
            i = bool1;
            continue;
            String str3 = getString(2131427335);
            Toast.makeText(this, str3, 1).show();
            RPCHelper localRPCHelper2 = RPCHelper.getInstance(getApplication());
            User localUser2 = this.mUser;
            String str4 = this.mFavId;
            boolean bool2 = localRPCHelper2.attendTopic(localUser2, 1, str4);
            this.mBeRelated = 0;
            i = bool2;
          }
          StringBuilder localStringBuilder = new StringBuilder("#");
          String str5 = this.mQuery;
          String str6 = str5 + "#";
          Intent localIntent2 = Utils.editTopicBlog(this, str6);
          startActivity(localIntent2);
        }
      case 2131624248:
      }
    }
    catch (RPCHelper.HttpException localHttpException)
    {
      while (true)
      {
        continue;
        if (!this.mTaskFree)
          continue;
        this.loadMode = 1;
        reloadList();
      }
    }
  }

  public void onPause()
  {
    super.onPause();
    if (this.mPgToast != null)
      this.mPgToast.cancel();
    if ((!this.mTaskFree) && (this.mTask != null) && (!this.mTask.isCancelled()))
    {
      boolean bool = this.mTask.cancel(1);
      this.mTaskFree = 1;
    }
  }

  public boolean onPrepareOptionsMenu(Menu paramMenu)
  {
    MenuItem localMenuItem1 = paramMenu.findItem(2131624246);
    MenuItem localMenuItem2 = paramMenu.findItem(2131624245);
    int i;
    if (this.mBeRelated == 1)
    {
      i = 0;
      if (i == 0)
        break label70;
    }
    label70: int m;
    for (int k = 0; ; m = 1)
    {
      MenuItem localMenuItem3 = localMenuItem1.setVisible(k);
      MenuItem localMenuItem4 = localMenuItem2.setVisible(i);
      return true;
      int j = 1;
      break;
    }
  }

  protected void onResume()
  {
    super.onResume();
    int i = getSharedPreferences("readmode", 0).getInt("readmode", 0);
    if (this.mReadMode != i)
    {
      this.mReadMode = i;
      this.mAdapter.notifyDataSetChanged();
    }
    load_settings();
    Bundle localBundle = getIntent().getExtras();
    String str1 = localBundle.getString("uid");
    this.mUid = str1;
    String str2 = localBundle.getString("nick");
    this.mNick = str2;
    if ((this.mUid == null) || (this.mUid.equals("")))
    {
      this.mUid = null;
      if (this.mCurNick != null)
      {
        String str3 = this.mCurNick;
        String str4 = this.mNick;
        if (str3.equals(str4));
      }
      else
      {
        this.mList = null;
      }
      this.mMode = 0;
      if ((this.mUsername != null) && (this.mPassword != null) && (this.mUsername.length() != 0) && (this.mPassword.length() != 0))
        break label237;
      Intent localIntent = new Intent(this, SwitchUser.class);
      startActivityForResult(localIntent, 0);
    }
    while (true)
    {
      return;
      if (this.mCurUid != null)
      {
        String str5 = this.mUid;
        String str6 = this.mCurUid;
        if (str5.equals(str6))
          break;
      }
      this.mList = null;
      break;
      label237: if ((this.mList != null) || (!this.mTaskFree))
        continue;
      reloadList();
    }
  }

  protected void reloadList()
  {
    reloadBegine(1);
    this.mBeReload = 1;
    this.mPage = 1;
    this.mNewCount = 0;
    if (this.mTaskFree)
    {
      String str = String.valueOf(this.mPage);
      ListBaseActivity.FetchDataTask localFetchDataTask1 = new ListBaseActivity.FetchDataTask(this);
      this.mTask = localFetchDataTask1;
      ListBaseActivity.FetchDataTask localFetchDataTask2 = this.mTask;
      String[] arrayOfString = new String[1];
      arrayOfString[0] = str;
      AsyncTask localAsyncTask = localFetchDataTask2.execute(arrayOfString);
    }
    this.mExpectItem = 1;
  }

  protected void saveListCache(int paramInt, List<?> paramList)
  {
  }

  protected void setContentView()
  {
    setView(2130903093);
  }

  class WeiboTopicListAdapter extends BaseAdapter
  {
    private Context mContext;

    public WeiboTopicListAdapter(Context arg2)
    {
      Object localObject;
      this.mContext = localObject;
    }

    public int getCount()
    {
      int i;
      if (UserTopicAttentionList.this.mList == null)
        i = 0;
      while (true)
      {
        return i;
        int j = UserTopicAttentionList.this.mList.size();
        int k = UserTopicAttentionList.this.mTotals;
        if (j < k)
        {
          i = UserTopicAttentionList.this.mList.size() + 2;
          continue;
        }
        i = UserTopicAttentionList.this.mList.size() + 1;
      }
    }

    public Object getItem(int paramInt)
    {
      return Integer.valueOf(paramInt);
    }

    public long getItemId(int paramInt)
    {
      return paramInt;
    }

    public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
    {
      paramInt += -1;
      Object localObject1;
      if (paramInt == -1)
        localObject1 = UserTopicAttentionList.this.getReloadView();
      while (true)
      {
        for (Object localObject2 = localObject1; ; localObject2 = null)
        {
          return localObject2;
          if (UserTopicAttentionList.this.mList != null)
            break;
        }
        int i = UserTopicAttentionList.this.mList.size();
        if (paramInt == i)
        {
          localObject1 = UserTopicAttentionList.this.getLoadMoreView();
          continue;
        }
        int j = 1;
        int k = 0;
        int m = UserTopicAttentionList.this.mMode;
        if (paramView == null)
        {
          Context localContext1 = this.mContext;
          ListView localListView1 = UserTopicAttentionList.this.mLvUser;
          MBlog localMBlog1 = (MBlog)UserTopicAttentionList.this.mList.get(paramInt);
          int n = UserTopicAttentionList.this.mReadMode;
          localObject1 = new MBlogListItemView(localContext1, localListView1, localMBlog1, j, k, 0, 0, n);
          continue;
        }
        localObject1 = paramView;
        try
        {
          MainListItemView localMainListItemView = (MainListItemView)localObject1;
          Object localObject3 = UserTopicAttentionList.this.mList.get(paramInt);
          int i1 = UserTopicAttentionList.this.mReadMode;
          localMainListItemView.update(localObject3, j, k, 0, i1);
        }
        catch (Exception localException)
        {
          Context localContext2 = this.mContext;
          ListView localListView2 = UserTopicAttentionList.this.mLvUser;
          MBlog localMBlog2 = (MBlog)UserTopicAttentionList.this.mList.get(paramInt);
          int i2 = UserTopicAttentionList.this.mReadMode;
          localObject1 = new MBlogListItemView(localContext2, localListView2, localMBlog2, j, k, 0, 0, i2);
        }
      }
    }

    public void refresh()
    {
      notifyDataSetChanged();
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     com.sina.weibo.UserTopicAttentionList
 * JD-Core Version:    0.6.0
 */